import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/student',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '学生信息管理系统', icon: 'dashboard' }
    }]
  },
  // 学生
  {
    path: '/student',
    component: Layout,
    redirect: '/student/list',
    name: 'student',
    meta: { title: '学生管理', icon: 'peoples' },
    children: [
      {
        path: 'list',
        name: 'StudentList',
        component: () => import('@/views/student/student/list'),
        meta: { title: '学生列表' }
      },
      {
        path: 'create',
        name: 'StudentCreate',
        component: () => import('@/views/student/student/form'),
        meta: { title: '添加学生' }
      },
      {
        path: 'edit/:id',
        name: 'StudentEdit',
        component: () => import('@/views/student/student/form'),
        meta: { title: '编辑学生', noCache: true },
        hidden: true
      },
      {
        path: 'import',
        name: 'StudentImport',
        component: () => import('@/views/student/student/import'),
        meta: { title: '导入学生信息' }
      }
    ]
  },

  // 院系
  {
    path: '/department',
    component: Layout,
    redirect: '/department/list',
    name: 'department',
    meta: { title: '院系管理', icon: 'component' },
    children: [
      {
        path: 'list',
        name: 'DepartmentList',
        component: () => import('@/views/student/department/list'),
        meta: { title: '院系列表' }
      },
      {
        path: 'create',
        name: 'DepartmentCreate',
        component: () => import('@/views/student/department/form'),
        meta: { title: '添加院系' }
      },
      {
        path: 'edit/:id',
        name: 'DepartmentEdit',
        component: () => import('@/views/student/department/form'),
        meta: { title: '编辑院系', noCache: true },
        hidden: true
      }
    ]
  },
  // 专业
  {
    path: '/major',
    component: Layout,
    redirect: '/major/list',
    name: 'major',
    meta: { title: '专业管理', icon: 'component' },
    children: [
      {
        path: 'list',
        name: 'MajorList',
        component: () => import('@/views/student/major/list'),
        meta: { title: '专业列表' }
      },
      {
        path: 'create',
        name: 'MajorCreate',
        component: () => import('@/views/student/major/form'),
        meta: { title: '添加专业' }
      },
      {
        path: 'edit/:id',
        name: 'MajorEdit',
        component: () => import('@/views/student/major/form'),
        meta: { title: '编辑专业', noCache: true },
        hidden: true
      }
    ]
  },
  // 年级
  {
    path: '/grade',
    component: Layout,
    redirect: '/grade/list',
    name: 'grade',
    meta: { title: '年级管理', icon: 'component' },
    children: [
      {
        path: 'list',
        name: 'GradeList',
        component: () => import('@/views/student/grade/list'),
        meta: { title: '年级列表' }
      },
      {
        path: 'create',
        name: 'GradeCreate',
        component: () => import('@/views/student/grade/form'),
        meta: { title: '添加年级' }
      },
      {
        path: 'edit/:id',
        name: 'GradeEdit',
        component: () => import('@/views/student/grade/form'),
        meta: { title: '编辑年级', noCache: true },
        hidden: true
      }
    ]
  },
  // 班级
  {
    path: '/class',
    component: Layout,
    redirect: '/class/list',
    name: 'class',
    meta: { title: '班级管理', icon: 'component' },
    children: [
      {
        path: 'list',
        name: 'ClassList',
        component: () => import('@/views/student/classs/list'),
        meta: { title: '班级列表' }
      },
      {
        path: 'create',
        name: 'ClassCreate',
        component: () => import('@/views/student/classs/form'),
        meta: { title: '添加班级' }
      },
      {
        path: 'edit/:id',
        name: 'ClassEdit',
        component: () => import('@/views/student/classs/form'),
        meta: { title: '编辑班级', noCache: true },
        hidden: true
      }
    ]
  },

  // {
  //   path: '/basic',
  //   component: Layout,
  //   redirect: '/department/list',
  //   name: 'basic',
  //   meta: {
  //     title: '基础设置',
  //     icon: 'nested'
  //   },
  //   children: [
  //     {
  //       path: 'department',
  //       component: () => import('@/views/nested/menu1/index'), // Parent router-view
  //       name: 'Menu1',
  //       meta: { title: 'Menu1' },
  //       children: [
  //         {
  //           path: 'menu1-1',
  //           component: () => import('@/views/nested/menu1/menu1-1'),
  //           name: 'Menu1-1',
  //           meta: { title: 'Menu1-1' }
  //         },
  //         {
  //           path: 'menu1-2',
  //           component: () => import('@/views/nested/menu1/menu1-2'),
  //           name: 'Menu1-2',
  //           meta: { title: 'Menu1-2' },
  //           children: [
  //             {
  //               path: 'menu1-2-1',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  //               name: 'Menu1-2-1',
  //               meta: { title: 'Menu1-2-1' }
  //             },
  //             {
  //               path: 'menu1-2-2',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  //               name: 'Menu1-2-2',
  //               meta: { title: 'Menu1-2-2' }
  //             }
  //           ]
  //         },
  //         {
  //           path: 'menu1-3',
  //           component: () => import('@/views/nested/menu1/menu1-3'),
  //           name: 'Menu1-3',
  //           meta: { title: 'Menu1-3' }
  //         }
  //       ]
  //     },
  //     {
  //       path: 'menu2',
  //       component: () => import('@/views/nested/menu2/index'),
  //       meta: { title: 'menu2' }
  //     }
  //   ]
  // },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
